<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>share with me top view</title>
<meta charset="UTF-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.max-width-height-image {
	height: 132;
	width: 91;
}
</style>

</head>
<body>
	<div id="background">

		<div id="page">

			<div class="header">
				<div class="footer">
					<div class="body">




						<jsp:include page="Menu.jsp" flush="True">
							<jsp:param name="page_call" value="TopView" />
						</jsp:include>
						<div id="content">
							<img src="images/cotton-flower.jpg" width="726" height="546"
								alt="" title="">
							<div class="pagetitlebar">
								<span style="margin-left: 350px; font-size: 15px;"> </span>
							</div>

							<sql:setDataSource dataSource="jdbc/sharewithme"
								var="sharewithme" />
							<c:catch var="ex">

							</c:catch>

							<div class="pagecontent">
								<sql:query var="topViews" dataSource="${sharewithme}">
												select bisbn,bnamethai,bwriter,countview 
												from tbtopview tv inner join tbbooks b on tv.isbn = b.bisbn
												order by countview desc
												limit 3
											</sql:query>
								<h3 style="border-bottom: solid white 1px;">Top view</h3>
								<table>
									<c:forEach items="${topViews.rows}" var="topviewItem">
										<tr>
											<td align="center">
												<div class="max-width-height-image">
													<a href="ShareWithMe_detail.jsp?bisbn=${topviewItem.bisbn}">

														<img
														src="/ShareWithMe/BookCoverImage?isbn=${topviewItem.bisbn }"
														alt="ภาพปก" width="90" height="130" />

													</a>
												</div>
											</td>
											<td style="width: 100%;">ชื่อหนังสือ:
												${topviewItem.bnamethai}<br> ผู้แต่ง:
												${topviewItem.bwriter}<br> จำนวนผู้เข้าชม:
												${topviewItem.countview} ท่าน<br> <sql:query
													dataSource="jdbc/sharewithme" var="rs">
select ROUND (sum(tbshare.sharevalue)/topview.countrate ,1) as ratepoint ,
topview.countrate    
from sharewithme.tbshare tbshare, sharewithme.tbtopview topview
where tbshare.sharegroupid = 5
and tbshare.sharetypeid = 3
and tbshare.isbn = '${topviewItem.bisbn }'
and tbshare.isbn = topview.isbn
</sql:query> คะแนน: <c:if test="${rs.rows[0].ratepoint == null }">ยังไม่มีคน vote</c:if>${rs.rows[0].ratepoint }
											</td>
										</tr>
										<tr>
											<td></td>
											<td><div style="border-bottom: solid white 1px;"></div></td>
										</tr>
									</c:forEach>
									<tr>
										<td></td>
										<td>&nbsp;</td>
									</tr>
								</table>


								<sql:query var="topComment" dataSource="${sharewithme}">
												select bisbn,bnamethai,bwriter,countcomment 
												from tbtopview tv inner join tbbooks b on tv.isbn = b.bisbn
												order by countcomment desc
												limit 3
											</sql:query>
								<h3 style="border-bottom: solid white 1px;">Top comment</h3>
								<table>
									<c:forEach items="${topComment.rows}" var="topcommentItem">
										<tr>
											<td align="center"><a
												href="ShareWithMe_detail.jsp?bisbn=${topcommentItem.bisbn}">
													<img
													src="/ShareWithMe/BookCoverImage?isbn=${topcommentItem.bisbn }"
													alt="ภาพปก" width="90" height="130" />
											</a></td>
											<td style="width: 100%;">ชื่อหนังสือ:
												${topcommentItem.bnamethai}<br> ผู้แต่ง:
												${topcommentItem.bwriter}<br> จำนวน comment:
												${topcommentItem.countcomment} comments<br>
												 <sql:query
													dataSource="jdbc/sharewithme" var="rs">
select ROUND (sum(tbshare.sharevalue)/topview.countrate ,1) as ratepoint ,
topview.countrate    
from sharewithme.tbshare tbshare, sharewithme.tbtopview topview
where tbshare.sharegroupid = 5
and tbshare.sharetypeid = 3
and tbshare.isbn = '${topcommentItem.bisbn }'
and tbshare.isbn = topview.isbn
</sql:query> คะแนน: <c:if test="${rs.rows[0].ratepoint == null }">ยังไม่มีคน vote</c:if>${rs.rows[0].ratepoint }
											</td>
										</tr>
										<tr>
											<td></td>
											<td><div style="border-bottom: solid white 1px;"></div></td>
										</tr>
									</c:forEach>
									<tr>
										<td></td>
										<td>&nbsp;</td>
									</tr>
								</table>

								<sql:query var="topRate" dataSource="${sharewithme}">
												select bisbn,bnamethai,bwriter,countrate 
												from tbtopview tv inner join tbbooks b on tv.isbn = b.bisbn
												order by countrate desc
												limit 3
											</sql:query>
								<h3 style="border-bottom: solid white 1px;">Top rate</h3>
								<table>
									<c:forEach items="${topRate.rows}" var="toprateItem">
										<tr>
											<td align="center"><a
												href="ShareWithMe_detail.jsp?bisbn=${toprateItem.bisbn}">
													<img
													src="/ShareWithMe/BookCoverImage?isbn=${toprateItem.bisbn }"
													alt="ภาพปก" width="90" height="130" />
											</a></td>
											<td style="width: 100%;">ชื่อหนังสือ:
												${toprateItem.bnamethai}<br> ผู้แต่ง:
												${toprateItem.bwriter}<br> จำนวน rate:
												${toprateItem.countrate}<br>
												 <sql:query
													dataSource="jdbc/sharewithme" var="rs">
select ROUND (sum(tbshare.sharevalue)/topview.countrate ,1) as ratepoint ,
topview.countrate    
from sharewithme.tbshare tbshare, sharewithme.tbtopview topview
where tbshare.sharegroupid = 5
and tbshare.sharetypeid = 3
and tbshare.isbn = '${toprateItem.bisbn }'
and tbshare.isbn = topview.isbn
</sql:query> คะแนน: <c:if test="${rs.rows[0].ratepoint == null }">ยังไม่มีคน vote</c:if>${rs.rows[0].ratepoint }
											</td>
										</tr>
										<tr>
											<td></td>
											<td><div style="border-bottom: solid white 1px;"></div></td>
										</tr>
									</c:forEach>
								</table>
							</div>

							<p style="height: 50px;">&nbsp;</p>
						</div>


					</div>
				</div>
				<div class="shadow"></div>
			</div>
		</div>
	</div>
</body>
</html>
<body />
<html />